{view 'public/head'}
</head>
<body>
    <div class="container-fluid">
        <div id="legend" class="">
            <legend class="">修改产品</legend>
        </div>
        <form id='inventorywarehousing' class="form-horizontal" action="{site 'inventory/product_edit'}" accept-charset="utf-8" method="post">
            <input type="hidden" name="id" value="{$list.id}" />
            <input type="hidden" name="url" value="{$this->t_client->reffer()}" />
            <table class="table table-hover">
                <tr>
                    <th style="line-height:30px;text-align:right">产品分类<font color="#ff0000">*</font></th>
                    <td>
                        <select name="c_id" class="input-xlarge" required>
                            <option value="">请选择</option>
                            {loop $category as $var}
                            <option value="{$var.id}"{$list.c_id===$var.id?' selected':''}>{$var.name}</option>
                            {/loop}
                        </select>
                    </td>
                </tr>

                <tr>
                    <th style="line-height:30px;text-align:right">产品名称<font color="#ff0000">*</font></th>
                    <td><input type="text" name="name" placeholder="" value="{$list.name}" class="input-xlarge" required></td>
                </tr>
                <tr>
                    <th style="line-height:30px;text-align:right">产品货号<font color="#ff0000">*</font></th>
                    <td><input type="text" name="code" placeholder="" value="{$list.code}" class="input-xlarge" required></td>
                </tr>

                <tr>
                    <th style="line-height:30px;text-align:right">产品规格</th>
                    <td><input type="text" name="format" value="{$list.format}" placeholder="" class="input-xlarge"></td>
                </tr>
                <tr>
                    <th style="line-height:30px;text-align:right">最低库存报警</td>
                    <td><input type="text" name="lowest" placeholder="" value="{$list.lowest}" class="input-small"></td>
                </tr>

                <tr>
                    <th style="line-height:30px;text-align:right">产品单位</td>
                    <td>
                        <select name="unit" class="input-small">
                            <option value="">选择</option>
                            {loop $unit as $var}
                            <option value="{$var.u_name}">{$var.u_name}</option>
                            {/loop}
                        </select>
                        <input type="text" name="u_name" placeholder="" value="{$list.unit}" class="input-small">
                    </td>
                </tr>
                <tr>
                    <th style="line-height:30px;text-align:right">产品价格</th>
                    <td style="line-height:30px;">
                        <span class="muted">销售价 <font color="#ff0000">*</font> </span>
                        <input type="text" name="sales" value="{$list.sales}" placeholder="销售价" class="input-mini" required>
                        <span class="muted">进货价 <font color="#ff0000">*</font> </span>
                        <input type="text" name="purchase" value="{$list.purchase}" placeholder="进货价" class="input-mini" required>
                    </td>
                </tr>
                <tr>
                    <th style="line-height:30px;text-align:right">购买所需积分</th>
                    <td><input type="text" name="points" placeholder="" value="{$list.points}" class="input-small"></td>
                </tr>

                <tr>
                    <th style="line-height:30px;text-align:right">产品类型</th>
                    <td>
                        <label class="radio inline">
                            <input type="radio" value="1" name="type"{$list.type==='1'?' checked="checked"':''}>
                            正常
                        </label>
                        <label class="radio inline">
                            <input type="radio" value="2" name="type"{$list.type==='2'?' checked="checked"':''}>
                            赠品
                        </label>
                    </td>
                </tr>
                <tr>
                    <th style="line-height:30px;text-align:right">提成方式</th>
                    <td>
                        <label class="radio inline">
                            <input type="radio" value="1" name="deduct_type"{$list.deduct_type==='1'?' checked="checked"':''} onclick="$('#deduct').html('%')">
                            百分比 [%]
                        </label>
                        <label class="radio inline">
                            <input type="radio" value="2" name="deduct_type"{$list.deduct_type==='2'?' checked="checked"':''} onclick="$('#deduct').html('元')">
                            固定值 [元]
                        </label>
                    </td>
                </tr>
                <tr>
                    <th style="line-height:30px;text-align:right">提成值</th>
                    <td><input type="text" name="deduct" placeholder="" value="{$list.deduct}" class="input-small calculator">
                        <span id="deduct"></span>
                    </td>
                </tr>
                <tr>
                    <th style="line-height:30px;text-align:right">产品备注</th>
                    <td><textarea name="remark" type="" class="input-xlarge" style="height:60px">{$list.remark}</textarea></td>
                </tr>
                <tr>
                    <th style="line-height:30px;text-align:right"><span class="loading"><img src="{base 'assets/img/loading.gif'}"></span></th>
                    <td>
                        <button type="submit" class="btn btn-primary input-small"><i class="icon-save"></i> 保存</button> <button type="reset" class="btn input-small"><i class="icon-refresh"></i> 重置</button>
                        <a href="{$this->t_client->reffer()}" title="返回" class="btn"><i class="icon-double-angle-left"></i> 返回</a>
                    </td>
                </tr>
            </table>
        </form>

    </div>
    {view 'public/js'}
    <script type="text/javascript">
        $(document).ready(function () {
            //post_sisyphus();
            $('#autocomplete').autocomplete({
                serviceUrl: "{site 'json/product'}",
                onSelect: function (suggestion) {
                    $('#autocomplete').val(suggestion.code);
                    $('#productid').val(suggestion.id);
                    $('#productname').val(suggestion.value);
                }
            });


        });
    </script>
</body>
</html>